package com.ly.web.controller.erp;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import com.ly.common.core.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ly.common.annotation.Log;
import com.ly.common.core.controller.BaseController;
import com.ly.common.enums.BusinessType;
import com.ly.heart.domain.EnsureEntity;
import com.ly.heart.service.IEnsureService;
import com.ly.common.utils.poi.ExcelUtil;
import com.ly.common.core.page.TableDataInfo;

/**
 * 交/退保证金记录Controller
 *
 * @author cxl
 * @date 2024-05-14
 */
@Api(value = "Ensure", tags = "交/退保证金记录")
@RestController
@RequestMapping("/heart/Ensure")
public class EnsureController extends BaseController
{
    @Resource
    private IEnsureService ensureService;

    /**
     * 查询交/退保证金记录列表
     */
    @PreAuthorize("@ss.hasPermi('heart:Ensure:list')")
    @GetMapping("/list")
    @ApiOperation("查询交/退保证金记录列表")
    public TableDataInfo list(EnsureEntity ensureEntity)
    {
        startPage();
        List<EnsureEntity> list = ensureService.selectEnsureEntityList(ensureEntity);
        return getDataTable(list);
    }

    /**
     * 导出交/退保证金记录列表
     */
    @PreAuthorize("@ss.hasPermi('heart:Ensure:export')")
    @Log(title = "交/退保证金记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出交/退保证金记录列表")
    public void export(HttpServletResponse response, EnsureEntity ensureEntity)
    {
        List<EnsureEntity> list = ensureService.selectEnsureEntityList(ensureEntity);
        ExcelUtil<EnsureEntity> util = new ExcelUtil<EnsureEntity>(EnsureEntity.class);
        util.exportExcel( list, "交/退保证金记录数据");
    }

    /**
     * 获取交/退保证金记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('heart:Ensure:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取交/退保证金记录详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(ensureService.selectEnsureEntityById(id));
    }

    /**
     * 新增交/退保证金记录
     */
    @PreAuthorize("@ss.hasPermi('heart:Ensure:add')")
    @Log(title = "交/退保证金记录", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增交/退保证金记录")
    public AjaxResult add(@RequestBody EnsureEntity ensureEntity)
    {
        return toAjax(ensureService.insertEnsureEntity(ensureEntity));
    }

    /**
     * 修改交/退保证金记录
     */
    @PreAuthorize("@ss.hasPermi('heart:Ensure:edit')")
    @Log(title = "交/退保证金记录", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改交/退保证金记录")
    public AjaxResult edit(@RequestBody EnsureEntity ensureEntity)
    {
        return toAjax(ensureService.updateEnsureEntity(ensureEntity));
    }

    /**
     * 删除交/退保证金记录
     */
    @PreAuthorize("@ss.hasPermi('heart:Ensure:remove')")
    @Log(title = "交/退保证金记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除交/退保证金记录")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(ensureService.deleteEnsureEntityByIds(ids));
    }
}
